import logging
import unittest
import requests
from ddt import ddt, file_data, data, unpack
from tolen.tlsc import Read
from tolen.Wause import write
from tolen.Tools import Tools

path = r"C:\Users\shuohan\Desktop\代码开发.xlsx"
sheetname = "Sheet1"

by = Read(path, sheetname)


@ddt
class Movie(unittest.TestCase):  # 建议使用TestCase结尾的类名
    host = 'http://10.59.9.18/'

    def setUp(self) -> None:
        print("初始化")
        self.W = write(path, sheetname)
        Tools().log()

    def tearDown(self) -> None:
        print("end")

    @file_data("user.json")
    def test_shang_001(self,email,pwd,expect):
        print(expect)
        url = Movie.host + "/movieApi/user/v2/login"
        data = {"email": email, "pwd": pwd}
        r1 = requests.post(url=url,
                           params=data)
        print(r1.json())
        Movie.userId = r1.json()["result"]["userId"]
        Movie.sessionId = r1.json()["result"]["sessionId"]
        print(Movie.userId, Movie.sessionId)

        index =int (str(Movie.userId).lstrip("0"))
        self.W.write(index+1,2,r1.json())
        logging.info("end_kjfkds")

if __name__ == '__main__':
    unittest.main()
